/**
 * Copyright 2019 [shujiang.yang], Inc. All rights reserved.
 * Email: 314938230@qq.com
**/
define("pages/crjdj/crjdj_dynamic", [
        "../../common/componts.js",
        "../../plugins/easyui/jquery-easyui-1.5.1/jquery.easyui.min",
        "../../plugins/easyui/jquery-easyui-1.5.1/easyloader",
        "../../plugins/artTemplate/artTemplate"
    ],
    function(require) {
        var componts = require("../../common/componts");
//        var queryTableId="awdDynamicQueryTableId";
        var selectid;

//        var getQueryDataGrid = function(){
//            return $("#"+queryTableId);
//        };

//        var tableInit=function(){
//            componts.initTable(queryTableId,{
//                url:"/crjdj/list",
//                title:'',
//                fit:true,
//                // firstLoad:true,
//                width:'100%',
//                columns :  [
//                    {field: 'id',title: '',width:30,hidden:true}
//                    ,{field:'drmj',title:'带入民警',width:20,sortable:'true',formatter: function(value){return value?'<span title="'+value+'">'+value+'</span>':'';}}
//                    ,{field:'drsjString',title:'带入时间',width:20,sortable:'true',formatter: function(value){return value?'<span title="'+value+'">'+value+'</span>':'';}}
//                    ,{field:'dcmj',title:'带出民警',width:20,sortable:'true',formatter: function(value){return value?'<span title="'+value+'">'+value+'</span>':'';}}
//                    ,{field:'dcsjString',title:'带出时间',width:20,sortable:'true',formatter: function(value){return value?'<span title="'+value+'">'+value+'</span>':'';}}
//                    ,{field:'dcyy',title:'带出原因',width:20,sortable:'true',formatter: function(value){return value?'<span title="'+value+'">'+value+'</span>':'';}}
//                    ,{field:'bz',title:'备注',hidden:true,width:20,sortable:'true',formatter: function(value){return value?'<span title="'+value+'">'+value+'</span>':'';}}
//                    ,{field:'djr',title:'登记人',width:20,sortable:'true',formatter: function(value){return value?'<span title="'+value+'">'+value+'</span>':'';}}
//                    ,{field:'djsjString',title:'登记时间',width:20,sortable:'true',formatter: function(value){return value?'<span title="'+value+'">'+value+'</span>':'';}}
//                ] ,
//                //基本信息双击事件
//                onDblClickRow:function(rowIndex, rowData){
//                    $("input[name='ryRadio']")[rowIndex].checked = true;
//                    getQueryDataGrid().datagrid("selectRow", rowIndex);
//                    selectid=rowData.id;
//                },
//                onLoadSuccess:function(data){
//                    if(data.total>0){
//                        getQueryDataGrid().datagrid("selectRow", 0);
//                        $("input[name='ryRadio']")[0].checked = true;
//                    }
//                },
//                //单击行选中取消事件
//                onClickRow:function(rowIndex, rowData){
//                    if(selectid!=rowData.id){
//                        $("input[name='ryRadio']")[rowIndex].checked = true;
//                        selectid=rowData.id;
//                    }else{
//                        getQueryDataGrid().datagrid("unselectRow",rowIndex);
//                        $("input[name='ryRadio']")[rowIndex].checked = false;
//                        getQueryDataGrid().datagrid('clearSelections');
//                        selectid="";
//                    }
//                }
//                });
//                //页面高度自适应
//                getQueryDataGrid().datagrid('resize',{
//                    height:($(window).height()-150)
//                });
//            };

        /**
         * 数据列表刷新加载
         */
        var loadDataGrid = function(){
            var formData = $(".awd-dynamic-query-form").serializeObject();
            var queryParams = $.extend({},formData,{"state":"R2"});
            $.ajax({
                type : "POST",
                url : '/xxxx/dynamic',
                data : queryParams,
                success : function(result) {
                    console.log(result);
                    if (result.success) {
                        $.messager.alert("确定","数据加载成功","info");
                    }else{
                        $.messager.alert("确定","数据加载失败","warn");
                    }
                },
                complete:function(){
                }
            });
        };

        var bindAction=function(){
            //查询
            $(".awd-dynamic-query-btn").on("click",function(){
                loadDataGrid();
            });

            /**
             * 绑定回车事件
             */
            $(window).keydown(function(event) {
                if (event.keyCode == 13) {
                    loadDataGrid();
                }
            });

        };

        //初始化
        (function(){
            componts.initSelectPage(undefined);
            componts.initSelect(undefined,undefined,undefined);
//            tableInit();
            bindAction();
        })()
    });
